<?php
/**
 * Created by PhpStorm.
 * User: gru
 * Date: 06/08/18
 * Time: 下午 06:07
 */

namespace App\Admin\Extensions\tools;

use Encore\Admin\Grid\Tools\AbstractTool;

class NewButton extends AbstractTool
{
    /**
     * @var string
     */
    private $url;
    /**
     * @var string
     */
    private $name;

    /**
     * @var string
     */
    private $target;

    /**
     * @var string
     */
    private $btnClass;

    /**
     * NewButton constructor.
     * @param string $url
     * @param string $name
     * @param string $target
     * @param string $btnClass
     */
    public function __construct(string $url, string $name, $target = '_self', string $btnClass = "btn-success")
    {

        $this->url = $url;
        $this->name = $name;
        $this->target = $target;
        $this->btnClass = $btnClass;
    }

    /**
     * Render CreateButton.
     *
     * @return string
     */
    public function render(): string
    {
        return <<<EOT

<div class="btn-group pull-right" style="margin-right: 10px">
    <a href="{$this->url}" target="{$this->target}" class="btn btn-sm {$this->btnClass}">
        <i class="fa fa-save"></i>&nbsp;&nbsp;$this->name
    </a>
</div>

EOT;
    }
}